package com.yoki.cloud.common.protocol.radius.attribute.attr.check;

import com.yoki.cloud.common.protocol.radius.attribute.attr.type.IntegerTypeAttr;
import lombok.Getter;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2018/1/15$ 14:54$
 */
public class LoginServiceAttr extends IntegerTypeAttr {

    public static final int ATTR_TYPE = 15;

    @Override
    public int getAttrType() {
        return ATTR_TYPE;
    }

    public LoginServiceTypeEnum getLoginServiceType() {
        return LoginServiceTypeEnum.getByValue(this.value);
    }

    enum LoginServiceTypeEnum {

        Telnet(0, "Telnet"),
        Rlogin(1, "Rlogin"),
        TCPClear(2, "TCP Clear"),
        PortMaster(3, "PortMaster"),
        LAT(4, "LAT"),
        X25_PAD(5, "X25-PAD"),
        X25_T3POS(6, "X25-T3POS"),
        TCPClearQuiet(7, "TCP Clear Quiet (suppresses any NAS-generated connect string)");

        @Getter
        private int value;
        @Getter
        private String name;

        LoginServiceTypeEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public static LoginServiceTypeEnum getByValue(Integer value) {
            if (null == value) {
                throw new IllegalArgumentException();
            }
            LoginServiceTypeEnum[] enums = LoginServiceTypeEnum.values();
            for (LoginServiceTypeEnum e : enums) {
                if (e.getValue() == value.intValue()) {
                    return e;
                }
            }
            return null;
        }

    }

}


